//
//  PersonHeaderView.m
//  MiaoTu
//
//  Created by dllo on 16/9/1.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "PersonHeaderView.h"
#import "Items.h"
#import "UIImageView+WebCache.h"

@interface PersonHeaderView ()
@property (weak, nonatomic) IBOutlet UILabel *likeLabel;
@property (weak, nonatomic) IBOutlet UILabel *likedLabel;
@property (weak, nonatomic) IBOutlet UILabel *emotionLabel;
@property (weak, nonatomic) IBOutlet UILabel *wantGoLabel;
@property (weak, nonatomic) IBOutlet UIImageView *headImage;
@property (weak, nonatomic) IBOutlet UILabel *genderLabel;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@end

@implementation PersonHeaderView

- (void)setItems:(Items *)items {
    _items = items;
    _likeLabel.text = @(items.LikeCount).stringValue;
    _likedLabel.text = @(items.LikedCount).stringValue;
    _emotionLabel.text = items.MaritalStatus;
    _wantGoLabel.text = items.WantGo;
    [_headImage sd_setImageWithURL:[NSURL URLWithString:items.HeadUrl] placeholderImage:[UIImage imageNamed:@"defaultHeadImage"]];
    _genderLabel.text = items.Gender;
    _nameLabel.text = items.Nickname;
    
    if ([_items.Gender isEqualToString:@"男"]) {
        _genderLabel.backgroundColor = [UIColor colorWithRed:0.494 green:0.588 blue:0.933 alpha:1.000];
    } else {
        _genderLabel.backgroundColor = [UIColor colorWithRed:0.843 green:0.400 blue:0.529 alpha:1.000];
    }
}

+ (instancetype)headerView {
    NSArray *nibView = [[NSBundle mainBundle] loadNibNamed:@"PersonHeaderView" owner:self options:nil];
    return [nibView objectAtIndex:0];
}

@end
